package com.mars.ticket.controller;

import com.mars.ticket.request.TicketOrderRequest;
import com.mars.ticket.response.result.R;
import org.springframework.web.bind.annotation.*;
import lombok.AllArgsConstructor;

import java.util.Arrays;

import com.mars.ticket.entity.TicketOrder;
import com.mars.ticket.service.ITicketOrderService;

/**
 * TicketOrder 控制层
 *
 * @Author wq
 * @Date 2021-04-22
 **/
@RestController
@RequestMapping("/ticketOrder")
@AllArgsConstructor
public class TicketOrderController {

    private final ITicketOrderService ticketOrderService;

    @GetMapping("/createOrder")
    public R createOrder(Integer userId, Integer ticketId, String username, String idCard) {
        ticketOrderService.createOrder(userId, ticketId, username, idCard);
        return R.success();
    }

    @PostMapping("/list")
    public R list(@RequestBody TicketOrderRequest request) {
        return R.success(ticketOrderService.list(request));
    }

    @GetMapping("/orderList")
    public R orderList(Integer userId) {
        return R.success(ticketOrderService.orderList(userId));
    }

    @GetMapping("/delete")
    public R delete(String orderId) {
        ticketOrderService.delete(orderId);
        return R.success();
    }


}